package com.freshcity.page.wait
{
	import com.freshcity.component.WaitIcon;
	import com.freshcity.component.container.Component;
	import com.freshcity.core.OpCodes;
	import com.freshcity.graphics.RoomInfoBack;
	import com.freshcity.utils.StringUtil;
	import com.greensock.TimelineMax;
	import com.greensock.TweenLite;
	
	import flash.events.MouseEvent;
	import flash.text.TextField;

	public class RoomInfo extends Component
	{
		public var owner:RoomList;

		private var background:RoomInfoBack;
		private var room:*;
		private var timeLine:TimelineMax;
		private var icon:WaitIcon;
		
		public function RoomInfo(room:*,xpos:Number=0,ypos:Number=0)
		{
			this.room=room;
			//this.width = 325;
			//this.height = 110;
			super(null,xpos,ypos);
		}		
		
		override protected function addChildren():void
		{
			super.addChildren();
			background=new RoomInfoBack();
			background.nameLabel.text=room.name;
			background.talkAmt.text=room.talker;
			background.roomDesc.text=room.info;
			this.room=room;
		
			icon=new WaitIcon(235, 3);
			icon.room = room;
			background.addChild(icon);
			
			//var roomType:MovieClip = new RoomTypeIcon();
			//background.addChild(roomType);
			
			background.roomType.gotoAndStop("type_"+room.type);
			addChild(background);
			
			background.enterBtn.addEventListener(MouseEvent.CLICK, onEnterHandler);
		}
		
		override public function draw():void
		{
			super.draw();
			this.icon.main = owner.group;
			
			if(room.type==0&&owner.group.user.level>=8){
				var t3:TextField = StringUtil.addHyLink("切换城市","",owner.onVisitCities);
				t3.x = 10;
				t3.y = 50;
				background.addChild(t3);			
			}
		}

		protected function onEnterHandler(event:MouseEvent):void
		{
			owner.queryRoom = room;
			owner.group.commu.send(OpCodes.WAIT_TALK, {room: room.id},owner.onWaitTalk);
		}
		
		private function onLineList(data:*):void
		{
			owner.win.tipMsg.text = "请选择搭乘巴士线路：";
			var rl:LineList=owner.lineBox;
			rl.show(data);
			
			var myfun:Function = function():void{
				owner.win.addChild(rl);
			};
			
			TweenLite.to(rl,0.5,{onInit:myfun,x:10});
		}

	}
}
